package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import main.model.Component;
import controller.editor.EditorController;

public class EditMenuView extends JPopupMenu{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static EditMenuView instance = null;
	
	private EditorController controller;
	private Component component;
	
	public EditMenuView(){
		super();
		JMenuItem item = new JMenuItem("Editar");
	    item.addActionListener(new ActionListener() {
	      public void actionPerformed(ActionEvent e) {
	    	  controller.editComponent(component);
	      }
	    });
	    add(item);

	    item = new JMenuItem("Eliminar");
	    item.addActionListener(new ActionListener() {
	      public void actionPerformed(ActionEvent e) {
	    	  controller.deleteDialog(component);
	      }
	    });
	    add(item);
	}
	
	public static EditMenuView getInstance(){
		if (instance == null){
			instance = new EditMenuView();
		}
		return instance;
	}

	public void setController(EditorController controller) {
		this.controller = controller;
	}

	public void setComponent(Component component2) {
		this.component = component2;
	}

}
